package com.lrs.java.dataStructure.stack_queue;

class StackX {

	private int max;
	private long[] stackArray;
	private int top;
	
	public StackX(int capacity) {
		this.max = capacity;
		stackArray = new long[capacity];
		top = -1;
	}

	public void push(long value) {
		top++;
		stackArray[top] = value;
		
		//stackArray[++top] = value;
	}		

	public long pop() {
		long topValue = stackArray[top];
		top--;
		
		//return stackArray[top--];
		
		return topValue;
	}
	
	public long peek() {
		return stackArray[top];
	}
	
	public boolean isEmpty() {
		return top == -1;
	}

	public boolean isFull() {
		return top == max-1;
	}
	
}

class StackApp {
	public static void main(String[] args) {
		
		StackX stack = new StackX(10);
		
		stack.push(20);
		stack.push(40);
		stack.push(80);
		
		while(!stack.isEmpty()) {
			System.out.print(stack.pop() + " ");
		}
		
	}
}
